package py.org.atom.seam.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class SHA1 {
	
    private static MessageDigest md;
    private static byte[] buffer, digest;
    private static String hash = "";

    public static String getPwd(String in){
    	String out = "7550b672e162c224c309bdea5d48ca975081a904";
    	try {
			out = getHash(in);
		} catch (NoSuchAlgorithmException e) {
			//
		}
		return out;
    }
    
    public static String getHash(String message) throws NoSuchAlgorithmException {
    	hash = "";
        buffer = message.getBytes();
        md = MessageDigest.getInstance("SHA1");
        md.update(buffer);
        digest = md.digest();

        for(byte aux : digest) {
            int b = aux & 0xff;
            if (Integer.toHexString(b).length() == 1) hash += "0";
            hash += Integer.toHexString(b);
        }

        return hash;
    }
    
    public static void main(String[] args) throws NoSuchAlgorithmException {
    	System.out.println(getHash("change"));
    }
}
